package com.control;
import com.service.IBatchCompareService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/compare")
public class BatchCompareControl {

    private final static Logger logger = LoggerFactory.getLogger(BatchCompareControl.class);


    @Autowired
    IBatchCompareService iBatchCompareService ;

    @RequestMapping("/i17")
    public void compareInfo(HttpServletRequest request){

        String batNo = request.getParameter("batNo");

        logger.info("============比对batNo"+batNo);

        Map<String,Object> map=new HashMap<>();

        String sourceTable = request.getParameter("sourceTable");
        String pageNo = request.getParameter("page");
         if(null==pageNo||"".equals(pageNo)){
             map.put("v_start",1);
             map.put("v_end",1000);
         }else{
             map.put("v_start",Integer.parseInt(pageNo)*1000);
             map.put("v_end",Integer.parseInt(pageNo)*1000+1000);
         }
        map.put("batNo",batNo);
        map.put("source_table",sourceTable);
        iBatchCompareService.compareInfo(map);
    }

 /*   @RequestMapping("/query")
    public List<ServiceInstance> test(HttpServletRequest request){

        String batNo = request.getParameter("batNo");
        logger.info("============比对batNo"+batNo);
        List<ServiceInstance> serviceInstanceList = discoveryClient.getInstances("service-provider-demo");
        return serviceInstanceList;

    }*/
}
